import { BlogModel } from '@/api/cms/blog/BlogModel'
import { reactive } from 'vue'

export default function useBaseModel() {
    //表单绑定的数据
    const blogModel = reactive<BlogModel>({
        baseURL: '',
        title: '',
        theme: '',
        DefaultContentLanguage: '',
        paginate: 10,
        limit: 10,
        author: '',
        favicon: '',
        logo: '',
        darkLogo: '',
        description: '',
        dateFormat: '',
        blogGroupBy: '',
        latestPostsCount: 10,
        showAllPostsOnHomePage: 0,
        article_toc: 1,
        about_title: '',
        footer_since: 2022,
        footer_customText: ''
    })
    //表单验证规则
    const rules = reactive({
        baseURL: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写基础域名'
            }
        ],
        title: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写博客标题'
            },
            { min: 2, max: 255, message: '长度为2-255个字符', trigger: 'blur' }
        ],
        theme: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写博客主题'
            }
        ],
        DefaultContentLanguage: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写默认语言'
            }
        ],
        paginate: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写每页条数'
            }
        ],
        limit: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写列表限制数'
            }
        ],
        author: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写作者名称'
            },
            { min: 2, max: 255, message: '长度为2-255个字符', trigger: 'blur' }
        ],
        favicon: [
            {
                required: true,
                trigger: 'blur',
                message: '请上传favicon'
            }
        ],
        logo: [
            {
                required: true,
                trigger: 'blur',
                message: '请上传logo'
            }
        ],
        darkLogo: [
            {
                required: true,
                trigger: 'blur',
                message: '请上传深颜色logo'
            }
        ],
        description: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写博客说明'
            },
            { min: 2, max: 255, message: '长度为2-255个字符', trigger: 'blur' }
        ],
        about_title: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写关于我左侧标题'
            },
            { min: 2, max: 255, message: '长度为2-255个字符', trigger: 'blur' }
        ],
        footer_customText: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写页脚说明'
            },
            { min: 2, max: 255, message: '长度为2-255个字符', trigger: 'blur' }
        ]
    })

    return {
        blogModel,
        rules
    }
}
